home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Online / LineShare 3.3.1 / LineShare Scripts / NoFax - ARA&Data < prev    next >
Text File  |  1995-03-09  |  6KB  |  328 lines

  1. ! Version 3.0.3
  2. !
  3. !$ Use this script with ARA 1.0 or 2.0,
  4. !$ and a BBS, E-mail or other communication server software
  5. !
  6. !$ A cable for hardware handshaking is required
  7.  
  8. ^# Modem:
  9. ^3 Error Correction: = Bool("Enabled"="AUTO","Disabled"="NORM") "NORM"
  10. ^4 Handshake wires: = Bool("CTS+DTR"="&D0","CTS only"="&D2") "&D2"
  11. ^5 Answer On: = Enum("Never"="0","1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  12. ^6 Data Port Speed: = Enum("9600","19200","38400","57600") "19200"
  13. ! ------------------------------------------
  14. ! Resetting the modem:
  15. ! ------------------------------------------
  16. @Hangup
  17.   SetTries 2
  18.   Flush
  19.   HsReset 0,0,0,0,0,0
  20. !
  21. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  22. ! to enter the command mode
  23. !
  24. @Label 1
  25.   matchclr
  26.   matchstr 1 2 "OK\r\n"
  27.   write "ATH0V1Q0\r"
  28.   matchread 20
  29.   ChrDelay 1
  30.   Write "+++"
  31.   ChrDelay 0
  32.   SBreak
  33.   DtrClear
  34.   Pause 5
  35.   DtrSet
  36.   Pause 5
  37. !
  38.   DecTries
  39.   IfTries 0 1
  40. !
  41. ! OSErr -6019 "Modem error - the modem is not responding"
  42. !
  43.   exit -6019
  44. @Label 2
  45.   SetVar A "&F"
  46.   GetOption A "DFLT" 3
  47. @Label 3
  48.   Write "AT^A\r"
  49.   Jsr 100
  50.   exit 0
  51.  
  52. @Label 6
  53.   Say "This script cannot be used with this modem"
  54.   ifOriginate 7
  55.   pause 1800
  56. @Label 7
  57.   exit -6019
  58. ! ------------------------------------------
  59. !    Receiving incoming calls
  60. ! ------------------------------------------
  61. @ANSWER
  62. @Label 10
  63. !
  64. ! Set the modem preferred speed first
  65.   SerReset Val("^6"),0,8,1
  66.   Jsr 80
  67. !
  68. ! Set the common options
  69.   Jsr 70
  70. !
  71. ! Set the communication options:
  72. ! • Normal/AUTO Connection
  73. ! • HW flow control
  74. ! • CONNECT <DCE speed> or CARRIER/CONNECT
  75. !
  76.   GetOption A "HWHS" 6
  77.   GetOption B "^3" 6
  78.   GetOption C "LNRS" 6
  79.   Write "AT^A^B^C\r"
  80.   Jsr 100
  81. !
  82. ! Get the Speaker and the Ring Num options
  83.   GetCommand B "Data" "M"
  84.   GetCommand C "Data" "L"
  85.   SetVar A "S0=^5"
  86. !
  87. ! Fetch the tube after <A> rings, <B><C> - speaker options
  88.   Write "AT^A^B^C\r"
  89.   Jsr 100
  90. !
  91. ! Everything is ready - let's sit and wait for a call
  92. ! We'll wait for 2 minutes, then reinitiate the modem
  93.   Note "Waiting for a ARA or Data call…"
  94.   Jsr 90
  95.   IfStr D 20 "DATA"
  96.   Jump 10
  97.  
  98. !
  99. ! Data connection has been established (we read "CONNECT")
  100. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  101. ! if it was an incoming call, put the "RING" before the "CONNECT"
  102. !
  103. @Label 20
  104.   IfOpen "Data" 21
  105.   Jump 30
  106. @Label 21
  107.   IfOpen "ARA" 22
  108.   Jump 35
  109. @Label 22
  110.   Note "Waiting for an ARA frame"
  111.   MatchClr
  112.   MatchStr 1 23 "^$\r"
  113.   MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
  114.   MatchStr 3 29 "\01\27\02\29\01\02\01\06"
  115.   MatchRead 40
  116.   Jump 24
  117. @Label 23
  118.   QueueInput "^$\r"
  119. @Label 24
  120.   Note "Non-ARA call"
  121.   Jump 35
  122.  
  123. @Label 28
  124.   Note "ARA 1.0 call"
  125.   Jump 30
  126. @Label 29
  127.   Note "ARA 2.0 call"
  128.   Jump 30
  129.  
  130. @Label 30
  131.   QueueInput "\r\nCARRIER ^B\r\n"  
  132.   IfStr A 31 "NONE"
  133.   IfStr A 31 "None"
  134.   QueueInput "\r\nREL\r\n"
  135. @Label 31
  136.   IfOriginate 32
  137.   QueueInput "\r\nRING\r\n"
  138. @Label 32
  139.   Attach "ARA" (DTR)
  140.  
  141. @Label 35
  142.   GetSReg C "DATA" 4
  143.   QueueInput "\r^CCONNECT ^B\r^C"
  144.   ifOriginate 36
  145.   QueueInput "\r^CRING\r^C"
  146. @Label 36
  147.   HsReset 0,1,0,0,0,1
  148.   Attach "Data" (DTR,Escape,Break)
  149.  
  150. ! ------------------------------------------
  151. ! Originating a call through the "ARA" subport
  152. ! ------------------------------------------
  153. @ORIGINATE "ARA"
  154.   SerReset Val("^6"),0,8,1
  155.   Jsr 80
  156. !
  157. ! Set the common options
  158.   Jsr 70
  159. !
  160. ! Set the communication options:
  161. ! • Normal Connection
  162. ! • HW flow control
  163. ! • CONNECT <DCE speed> or CARRIER/CONNECT
  164. !
  165.   GetOption A "HWHS" 6
  166.   GetOption B "^3" 6
  167.   GetOption C "LNRS" 6
  168.   Write "AT^A^B^C\r"
  169.   Jsr 100
  170. !
  171. ! dial the number
  172.   Write "ATD^1\r"
  173. !
  174. ! Wait for a modem response
  175.   Jsr 90
  176.   IfStr D 30 "DATA"
  177.   Write "\r"
  178.   Exit -6019
  179.  
  180. ! ------------------------------------------
  181. ! Originating a call through the "DATA" subport
  182. ! ------------------------------------------
  183. @ORIGINATE "Data" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  184.   SerReset Val("^6"),0,8,1
  185.   Jsr 80
  186. !
  187. ! Set the common options
  188.   Jsr 70
  189. !
  190. ! Set the communication options:
  191. ! • Normal Connection
  192. ! • HW flow control
  193. ! • CONNECT <DCE speed> or CARRIER/CONNECT
  194. !
  195.   GetOption A "HWHS" 6
  196.   GetOption B "^3" 6
  197.   GetOption C "LNRS" 6
  198.   Write "AT^A^B^C\r"
  199.   Jsr 100
  200. !
  201. ! dial the number
  202.   Write "ATD^1\r"
  203.   HsReset *
  204. !
  205. ! Wait for a modem response
  206.   Jsr 90
  207.   IfStr D 35 "DATA"
  208.   Write "\r"
  209.   Exit -6019
  210.  
  211. !
  212. ! This section emits all modem commands sent from the client application
  213. ! For each set of commands the "OK" answer is awaited
  214. !
  215. @Label 60
  216.   EmitStart
  217. @Label 61
  218.   EmitCommand 62
  219.   Jsr 100
  220.   Jump 61
  221. @Label 62
  222.   return
  223. !
  224. ! This section initiates the modem before ANSWER and ORIGINATEs:
  225. ! reset on Dtr drop + DCD valid
  226. ! Verbal responses mode, no echo 
  227. !
  228. @Label 70
  229.   Write "AT^4&C1V1E0\r"
  230.   Jsr 100
  231.   return 
  232.  
  233. !
  234. ! This section syncronize the modem after the serial port speed switching
  235. !
  236. @Label 80
  237.   ChrDelay 1
  238.   Write "AT\r"
  239.   ChrDelay 0
  240.   Jsr 100
  241.   return
  242. !
  243. ! Error codes
  244. @Label 81
  245.   exit -6020
  246. @Label 82
  247.   exit -6022
  248. @Label 83
  249.   exit -6021
  250. @Label 84
  251.   exit -6023
  252.   
  253. !
  254. ! This subroutine waits for the modem response
  255. ! On exit, ^D contains the result code: "DATA" or "NONE"
  256. ! ^A contains the protocol used
  257. ! ^B contains the carrier speed
  258. ! If modem reports an error, the scripts exits with an error code
  259. !
  260. @Label 89
  261.   Note "Ring…"
  262.   Jump 91
  263.  
  264. @Label 90
  265.   SetVar A "NONE"
  266.   SetVar B ""
  267.   MatchClr
  268.   Matchstr 1 92 "CARRIER ^$\r\n"
  269.   Matchstr 2 93 "PROTOCOL: ^$\r\n"
  270.  
  271.   Matchstr 4 95 "CONNECT ^$/"
  272.   Matchstr 5 97 "CONNECT ^$\r\n"
  273.   Matchstr 6 89 "RING\r\n"
  274.   Matchstr 10 82 "BUSY\r\n"
  275.   MatchStr 11 83 "NO CARRIER\r\n"
  276.   MatchStr 12 84 "NO ANSWER\r\n"
  277.   MatchStr 13 81 "NO DIALTONE\r\n"
  278. @Label 91
  279.   Matchread 1200
  280.   SetVar D "NONE"
  281.   return
  282.  
  283. @Label 92
  284.   SetVar B "^$"
  285.   Jump 91
  286. @Label 93
  287.   SetVar A "^$"
  288.   Jump 91
  289.  
  290. ! CONNECT xxxx/XXXX was detected
  291. @Label 95
  292.   Jsr 98
  293.   MatchClr
  294.   MatchStr 1 96 "^$\r\n"
  295.   MatchRead 10
  296. @Label 96
  297.   SetVar A "^$"
  298.   SetVar D "DATA"
  299.   return
  300.  
  301. ! CONNECT xxx was detected
  302. @Label 97
  303.   Jsr 98
  304.   SetVar D "DATA"
  305.   return
  306.  
  307. @Label 98
  308.   ifStr B 99 ""
  309.   return
  310. @Label 99
  311.   SetVar B "^$"
  312.   return 
  313. !
  314. ! Processing the AT command:
  315. ! OK -> proceed
  316. ! ERROR or TimeOut ->exit -6019
  317. ! It can be called AFTER the "Write" command, since LineShare buffers input
  318. !
  319. @Label 100
  320.   MatchClr
  321.   MatchStr 1 102 "OK\r\n"
  322.   MatchStr 2 101 "ERROR\r\n"
  323.   MatchRead 20
  324. @Label 101
  325.   Exit -6019
  326. @Label 102
  327.   return
  328.